class_name ExpressionUtil

static func evaluate_expression(context:String,state_chart:StateChart,expression:String,default_value:Variant) -> Variant:
	var ex = Expression.new()
	var input_names = state_chart.expression_properties.keys()
	var result = ex.parse(expression,input_names)
	if result != OK:
		push_error("({0})解析{1}错误：{2}".format([context,expression,ex.get_error_text()]))
		return default_value
	var input_values:Array = []
	for input_name in input_names:
		input_values.append(state_chart.expression_properties[input_name])
	var excute_result = ex.execute(input_values)
	if ex.has_execute_failed():
		push_error("({0})执行{1}错误：{2}".format([context,expression,ex.get_error_text()]))
		return default_value
	return excute_result
